<template>
	<view>
		<view class="header acea-row row-center">
			<view :class="indx == 0? 'active':'' " @click="qie(0)"> 未回答<text></text></view>
			<view :class="indx == 1? 'active':'' " @click="qie(1)"> 已回答 <text></text></view>
		</view>
		<view class="list" v-for = 'val in list' @tap="wenxq(val.id,val.category_id)" >
			<view class="title"> {{val.post_title}}</view>
			<view class="time">{{val.published_time}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				indx:0
			}
		},
		onLoad() {
			this.orlist()
			var jweixin = require('jweixin-module')
			var that = this
			console.log(jweixin)
				var urls = window.location.href
			this.$api('/portal/index/jsconfig', {datas:{url:urls}}, function(res) {
				console.log(res)
				var s = res.data.data
				jweixin.config({
				    debug: false,
				    appId: s.appId,
				    timestamp: s.timestamp,
				    nonceStr: s.nonceStr,
				    signature:s.signature,
				    jsApiList: ["updateTimelineShareData","updateAppMessageShareData"]
				});
				jweixin.ready(function(){
			jweixin.updateTimelineShareData({
					title: '海绵医学院', // 分享标题
				    link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				    imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
				    success: function () {
				      // 设置成功
					  console.log(1)

				    }
			})
			jweixin.updateAppMessageShareData({
				title: '海绵医学院', // 分享标题
				desc: '一个专业/有态度的医学直播交流平台', // 分享描述
				link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
				success: function () {
				  // 设置成功
				}
			  })



				})
				jweixin.error(function(res){
					console.log(res)
				})
			})
		},
		methods: {
			qie(e){
				this.indx = e
					this.orlist()
			},
			wenxq(e,cid){
				uni.navigateTo({
					url:'../index-wxq/index-wxq?id='+e+"&cid="+cid
				})
			},
			orlist(){
				var that = this
				var user_id = uni.getStorageSync('ids')
				this.$api('/portal/index/mytw',{datas:{status:that.indx,user_id:user_id}},(res)=>{
					console.log(res)
					if(res.data.data.length == 0){
						uni.showToast({
							title:'什么都没有~',
							icon:'none',
							duration:1500
						})
					}
					that.list = res.data.data
				})
			}
		}
	}
</script>

<style>
	@import url("./wod-tw.css");
</style>
